package com.microHR.hr.service.impl;

import com.microHR.hr.mapper.SalaryMapper;
import com.microHR.hr.model.Salary;
import com.microHR.hr.model.SalaryExample;
import com.microHR.hr.service.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;

@Service
public class SalaryServiceImpl implements SalaryService {

    @Autowired
    private SalaryMapper salaryMapper;

    @Override
    public List<Salary> getAllSalaries() {
        SalaryExample example = new SalaryExample();
        return salaryMapper.selectByExample(example);
    }

    @Override
    public Integer addSalary(Salary salary) {
        salary.setCreatedate(new Date());
        return salaryMapper.insertSelective(salary);
    }

    @Override
    public Integer deleteSalaryById(Integer id) {
        return salaryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Integer updateSalaryById(Salary salary) {
        return salaryMapper.updateByPrimaryKey( salary);
    }
}
